package cn.edu.zafu.bigdata.sxa;

public class InvalidAgeException extends Exception{
    public InvalidAgeException(String s){
        super(s);
    }
    public static int checkAge(int age) throws InvalidAgeException{
        if(age<18){
            throw new InvalidAgeException("年龄不能小于18岁！");
        }
        return age;
    }

    public static void main(String[] args) {
        try{
            int age=15;
            int t=checkAge(age);
            System.out.println("您已通过验证！");
        }catch(InvalidAgeException err){
            System.out.println("报错："+err.getMessage());
        }
    }
}